package com.snopy.designPattern.structure.bridge.impl;

import com.snopy.designPattern.structure.bridge.inter.Device;

/**
 * @author snopy
 * @version 1.0.0
 * @classname Radio
 * @description
 * @email 77912204@qq.com
 * @date 2022/11/26 20:57
 */
public class Radio implements Device {
    private boolean on = false;
    private int volume = 30;
    private int channel = 1;
    @Override
    public boolean isEnabled() {
        return on;
    }

    @Override
    public void enabled() {
        this.on = true;
    }

    @Override
    public void disabled() {
        this.on = false;
    }

    @Override
    public int getVolume() {
        return volume;
    }

    @Override
    public void setVolume(int percent) {
        if (percent > 100){
            this.volume = 100;
        }else if (percent < 0){
            this.volume = 0;
        }else {
            this.volume = percent;
        }
    }

    @Override
    public int getChannel() {
        return channel;
    }

    @Override
    public void setChannel(int channel) {
        this.channel = channel;
    }

    @Override
    public void printStatus() {
        System.out.println("-------------------------------------");
        System.out.println("| I'm radio.");
        System.out.println("| I'm "+ (on ? "enabled":"disabled"));
        System.out.println("| Current volume is " + volume + "%");
        System.out.println("| Current channel is "+ channel);
        System.out.println("-------------------------------------\n");
    }
}
